This file contains a CD-ROM containing electronic copies of Appendices, A, B, C and D which are incorporated herein by reference.
Contained herein is material that is subject to copyright protection. The copyright owner has no objection to the facsimile reproduction of the patent disclosure by any person as it appears in the Patent and Trademark Office patent files or records, but otherwise reserves all rights to the copyright whatsoever.
1. Field of the Invention
The invention relates generally to the field of run-time execution engines and automated code generation. More particularly, the invention relates to a Coherent Object System Architecture (COSA) including a context free run-time execution engine and a control flow architecture useful for directing the execution of automatically and/or manually generated code.
2. Description of the Related Art
Current run-time execution engines are characterized by complicated chains of logic and inefficiency. FIG. 1 is a simplified example of a prior art run-time execution engine that interprets bytecodes for a Java virtual machine. Assuming the bytecode interpreter 100 is to support even a subset of the 200+different instructions that make up such a virtual machine, the switch-case statement beginning at line 5 becomes large rather quickly. For purposes of this example, behavior is shown for only two exemplary opcodes, OPC_PUTS and OPC_EXIT.
Briefly, according to the present example, each bytecode that is received causes the bytecode interpreter 100 to sequentially interpret and process each byte in the bytecode parameter. Depending upon the sophistication of the compiler, the effect of the large switch-case statement is often the same as if a set of if-then-elses had been coded. For instance, chains of tests would be required for the 100th opcode before arriving at the corresponding behavior. First, the interpreted opcode is compared to the first case, then the opcode is compared to the second case, and so on, until a successful comparison is made to the 100th case. One possible way to achieve more efficiency is to manipulate the switch-case statements in an intelligent manner. For example, the case statements may be arranged in an order that first evaluates those of the opcodes that are most commonly used or those that are able to be evaluated the fastest. Consequently, fewer tests will be performed during run-time and the code will execute faster. Of course, this shallow, code-tuning advice assumes run-time characteristics of the code to be executed can be anticipated with some level of certainty. In reality, the manner in which general purpose software will be exploited is far from predictable. As a result, unforeseen uses may hinder the intended optimizations and may actually degrade performance for some users.
Other limitations illustrated by this example include lack of maintainability and inflexibility both of which result from context dependencies. For example, when new opcodes are added, the bytecode interpreter 100 must be supplemented with multiple new case statements and it must be recompiled. In addition, prior art run-time execution engines have various other disadvantages that are overcome by aspects of the present invention, as described in the detailed description which follows.
A method and apparatus are described for controlling the execution of a software program. According to a first embodiment, control flow information including multiple states associated with a software program is made accessible. Each of the states includes information indicative of desired control flow of the software program and information indicative of desired behavior of the software program. A determination is made if a current status of the software program has a predetermined relationship with an expected state of execution of the software program. Based upon the result of the determination and the information indicative of desired behavior, the software program is caused to perform an action and caused to transition from the current state to a next state.
According to a second embodiment, specification of a control flow architecture associated with a software program is simplified to the provision of certain control flow information that is accessible to a control flow engine. The control flow information need only include information indicative of desired control flow of the software program and information indicative of desired behavior of the software program.
According to a third embodiment, a novel controller is provided. The controller includes a processor configured to execute instructions and a memory coupled to the processor. The memory has stored therein data representing sequences of instructions of a software program. The sequences of instructions when executed by the processor cause the processor to perform the steps described above for controlling the execution of the software program. In one embodiment, the controller is dynamically programmable allowing data representing one or more member functions, control flow information, and/or a control flow engine to be loaded into the memory.
According to a fourth embodiment, a run-time execution engine performs true dynamic binding. The run-time execution engine dynamically binds execution flow of a software program to one or more member functions of the software program by reading addresses of the one or more member functions out of a data segment of the software program.
According to a fifth embodiment of the present invention, an array may be initialized with dissimilar elements. An expansion macro replaces each function in an array of functions with a list of dissimilar parameters associated with the function. Additionally, addresses associated with one or more parameters are calculated as the expansion macro replaces the functions.
According to a sixth embodiment, an improved method of running a Java program is provided. A bytecode is received. If the bytecode has not previously been received, then the bytecode is translated into executable code, the executable code is run, and the executable code is stored. Otherwise, if the bytecode has previously been received, then the previously stored executable code for the bytecode is executed.
Other features of the present invention will be apparent from the accompanying drawings and from the detailed description which follows.